﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MethodWorx.Core.Extensions
{
    public static class IEnumerableExtensions
    {
        public static bool IsLast<T>(this IEnumerable<T> src, T check)
            where T : class
        {
            return (src.Last() == check);
        }

        public static bool IsFirst<T>(this IEnumerable<T> src, T check)
            where T : class
        {
            return (src.First() == check);
        }

        public static bool ContainsKeyCaseInsensitive<TValue>(this IDictionary<string, TValue> dict, string value)
        {
            foreach (var key in dict.Keys)
            {
                if (key.ToLower() == value.ToLower())
                    return true;
            }

            return false;
        }
    }
}
